//
//  KSLViewController.m
//  KSLMenuToolBar
//
//  Created by kensla on 14-8-13.
//  Copyright (c) 2014年 kensla. All rights reserved.
//

#import "KSLViewController.h"
#import "KSLMenuToolBar.h"
#import "KSLMenu.h"
#import "UIColor+HexToRgb.h"
@interface KSLViewController ()
@property (nonatomic,strong)KSLMenuToolBar *kslMenuToolBar;
@property (nonatomic, strong) NSMutableArray *menus;
@end

@implementation KSLViewController

- (NSMutableArray *)menus {
    if (!_menus) {
        _menus = [[NSMutableArray alloc] initWithCapacity:1];
    }
    return _menus;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self _setupTopScrollBar];
}


- (void)itemSelectedAtIndex:(NSUInteger)index{
    NSLog(@"%lu",(unsigned long)index);
}

- (void)_setupTopScrollBar {
    
    
    _kslMenuToolBar = [[KSLMenuToolBar alloc] initWithFrame:CGRectMake(0,64, CGRectGetWidth(self.view.bounds), 52)];
    
    _kslMenuToolBar.backgroundColor =[UIColor clearColor];
    _kslMenuToolBar.delegate =self;
    _kslMenuToolBar.selectedIndex = 0;
    [self.view addSubview:self.kslMenuToolBar];
    
    for (int i = 0; i < 3; i ++) {
        KSLMenu *menu = [[KSLMenu alloc] init];
        
        NSString *title = nil;
        NSString *iconName =nil;
        UIColor *bgColor =nil;
        switch (i) {
            case 0:
                title =@"视频";
                iconName =@"cameraIcon";
                bgColor =[UIColor colorWithHexString:@"#0e95ef" inAlpha:1];
                
                break;
            case 1:
                title = @"消息";
                iconName =@"sensorIcon";
                bgColor =[UIColor colorWithHexString:@"#f97051" inAlpha:1];
                break;
            case 2:
                title = @"图像";
                iconName =@"nvsIcon";
                bgColor =[UIColor colorWithHexString:@"#0CB68E" inAlpha:1];
                
                break;
            default:
                title = @"";
                break;
        }
        menu.title = title;
        
        menu.iconName =iconName;
        
        menu.titleNormalColor = [UIColor whiteColor];
        menu.titleFont = [UIFont boldSystemFontOfSize:15];
        menu.backgroundColor =bgColor;
        
        [self.menus addObject:menu];
        
    }
    
    _kslMenuToolBar.menus = self.menus;
    
    [_kslMenuToolBar reloadData];
    
}


@end
